// CMS.h : main header file for the CMS application
//
#pragma once

#ifndef __AFXWIN_H__
	#error "include 'stdafx.h' before including this file for PCH"
#endif


#include "stdafx.h"
#include "resource.h"       // main symbols
#include "fm.h"
#include "DlgMain.h"
#include "MySettings.h"
#include "DialogHistory.h"
#include "DlgAlarmList.h"
#include "dlgrtinfo.h"
#include "DlgTip.h"

// CCMSApp:
// See CMS.cpp for the implementation of this class
//
//v1.00.100
#define CMS_VERSION		2
#define CMS_REVISION	00
#define CMS_BUILD		200

class CCMSApp : public CWinApp
{
public:
	CCMSApp();
	HBITMAP m_hBmAlarmOffline;
	HBITMAP m_hBmAlarmLower;
	HBITMAP m_hBmAlarmUpper;
	HBITMAP m_hBmAlarmNormal;
	HBITMAP	m_hBmAlarm;

	bool        m_bLogin;
	BOOL		m_bNormalClose;

	CString m_strUserName;
	int		m_nUserPower;
	TCHAR	m_tszModulePath[MAX_PATH];
	TCHAR	m_tszLocalDataPath[MAX_PATH];
	TCHAR	m_tszPatientPath[MAX_PATH];
	TCHAR	m_tszLogPath[MAX_PATH];
	//TCHAR	m_tszADPath[MAX_PATH];
	CString m_strPort;

	CDlgMain*	m_pDlgMain;
	CDialogHistory m_DlgHistory;
	CDlgAlarmList* m_pDlgAlarmList;
//	CDlgRtInfo	m_DlgRtInfo;
//	CDlgTip		*m_pDlgTip;

	CString m_strConnectString;
	_ConnectionPtr m_pConnection;
	_ConnectionPtr m_pConnBackup;

	CString m_strDbUsername;
	CString m_strDbPassword;
/////////////////-----------------   settings   -----------------///////////////
	CMySettings m_MySettings;
	TCHAR m_szLogBuf[1024];

	unsigned long  m_nTotalTime;//demo
	unsigned long  m_nStartTime;//demo


// Overrides
public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
// Implementation
	afx_msg void OnAppAbout();
	DECLARE_MESSAGE_MAP()

public :
	bool InitDataBase();
	bool CheckDefaultAccount();
	bool ExitDataBase();

	void StartMonitor();
	void StopMonitor();

	void WriteLog(LPCTSTR pszLog);
	int GenStudyID();
	int CheckStudyIdExist(_ConnectionPtr cptr, int nStudyId);

};

//extern CCMSApp* pApp;

extern CCMSApp theApp;
